#include<bits/stdc++.h>
#define int long long
const int N = 4e5 + 10;
using namespace std;
int read(){
	int s = 0, f = 1; char c = getchar();
	while(!isdigit(c)){if(c == '-') f = -1; c = getchar();}
	while(isdigit(c)){s = s * 10 + c - '0'; c = getchar();}
	return s * f;
}
int n, l[N], r[N], m;
vector<int> s;
signed main(){
	freopen("kte.in", "r", stdin);
	freopen("kte.out", "w", stdout);
	n = read();
	s.push_back(1e18);
	while(n--){
		int x = read();
		auto pos = lower_bound(s.begin(), s.end(), x);
		if(*pos != x) s.insert(pos, x);
		else s.erase(pos);
		int i = 0;
		for(auto v : s) i++, l[i] = l[i - 1] + v;
		m = i - 1, i = 0; 
		auto p = s.end(); p--;
		do{
			p--, i++, r[i] = r[i - 1] + *p;
		}while(p != s.begin());
		int ans = 0;
 		for(int i = 1; i <= m; i++){
			r[i]--;
			ans += r[i] - l[i] + 1;
			if(r[i - 1] >= l[i]) ans -= r[i - 1] - l[i] + 1;
		}
		printf("%lld\n", ans);
	}
	return 0;
}
